Skip to content

Conversation

@PProfizi
Copy link
Contributor

@PProfizi PProfizi commented Oct 3, 2025

No description provided.

@PProfizi PProfizi requested a review from cbellot000 October 3, 2025 13:01
@PProfizi PProfizi self-assigned this Oct 3, 2025
@PProfizi PProfizi added the enhancement New feature or request label Oct 3, 2025
@PProfizi PProfizi requested a review from rafacanton October 3, 2025 13:10
@codecov
Copy link

codecov bot commented Oct 3, 2025

❌ 5 Tests Failed:

Tests completed Failed Passed Skipped
1778 5 1773 207
View the top 3 failed test(s) by shortest run time
test_server\test_server.py::test_server::TestServer::test_server_debug[server_config5]
Stack Traces | 0.335s run time
self = <test_server.TestServer object at 0x0000021D4BBF7DC0>
server_config = <ansys.dpf.core.server_factory.ServerConfig object at 0x0000021D4BBC08E0>
tmp_path = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi14')

    def test_server_debug(self, server_config, tmp_path):
        from pathlib import Path
    
        server_instance = start_local_server(config=server_config)
        server_instance.start_debug(tmp_path / Path("DEBUG_TEST_"))
        f = dpf.core.field_from_array([1.0], server=server_instance)
        fwd = dpf.core.operators.utility.forward(any=f, server=server_instance)
        fwd.run()
        server_instance.stop_debug()
        debug_folder = sorted(tmp_path.glob("DEBUG_TEST_*"))
        assert len(debug_folder) == 1
        init_path = debug_folder[0] / Path("init.log")
>       assert init_path.exists()
E       AssertionError: assert False
E        +  where False = exists()
E        +    where exists = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi14/DEBUG_TEST_2025_11_24-10-24-07/init.log').exists

test_server\test_server.py:194: AssertionError
test_server\test_server.py::test_server::TestServer::test_server_debug[server_config1]
Stack Traces | 0.414s run time
self = <test_server.TestServer object at 0x0000021D4BBF7880>
server_config = <ansys.dpf.core.server_factory.ServerConfig object at 0x0000021D4BB83DC0>
tmp_path = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi2')

    def test_server_debug(self, server_config, tmp_path):
        from pathlib import Path
    
        server_instance = start_local_server(config=server_config)
        server_instance.start_debug(tmp_path / Path("DEBUG_TEST_"))
        f = dpf.core.field_from_array([1.0], server=server_instance)
        fwd = dpf.core.operators.utility.forward(any=f, server=server_instance)
        fwd.run()
        server_instance.stop_debug()
        debug_folder = sorted(tmp_path.glob("DEBUG_TEST_*"))
        assert len(debug_folder) == 1
        init_path = debug_folder[0] / Path("init.log")
>       assert init_path.exists()
E       AssertionError: assert False
E        +  where False = exists()
E        +    where exists = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi2/DEBUG_TEST_2025_11_24-10-23-24/init.log').exists

test_server\test_server.py:194: AssertionError
test_server\test_server.py::test_server::TestServer::test_server_debug[server_config4]
Stack Traces | 0.44s run time
self = <test_server.TestServer object at 0x0000021D4BBF7D00>
server_config = <ansys.dpf.core.server_factory.ServerConfig object at 0x0000021D4BBC0880>
tmp_path = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi11')

    def test_server_debug(self, server_config, tmp_path):
        from pathlib import Path
    
        server_instance = start_local_server(config=server_config)
        server_instance.start_debug(tmp_path / Path("DEBUG_TEST_"))
        f = dpf.core.field_from_array([1.0], server=server_instance)
        fwd = dpf.core.operators.utility.forward(any=f, server=server_instance)
        fwd.run()
        server_instance.stop_debug()
        debug_folder = sorted(tmp_path.glob("DEBUG_TEST_*"))
        assert len(debug_folder) == 1
        init_path = debug_folder[0] / Path("init.log")
>       assert init_path.exists()
E       AssertionError: assert False
E        +  where False = exists()
E        +    where exists = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi11/DEBUG_TEST_2025_11_24-10-24-05/init.log').exists

test_server\test_server.py:194: AssertionError
test_server.test_server.TestServer::test_server_debug[None]
Stack Traces | 13s run time
self = <test_server.TestServer object at 0x7fa80e989780>, server_config = None
tmp_path = PosixPath('.../pytest-of-runner/pytest-2/test_server_debug_None_2')

    def test_server_debug(self, server_config, tmp_path):
        from pathlib import Path
    
        server_instance = start_local_server(config=server_config)
>       server_instance.start_debug(tmp_path / Path("DEBUG_TEST_"))

test_server/test_server.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../hostedtoolcache/Python/3.10.19....../x64/lib/python3.10.../dpf/core/server_types.py:730: in start_debug
    api.data_processing_set_debug_trace(text=str(folder_path))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

text = '.../pytest-of-runner/pytest-2/test_server_debug_None_2/DEBUG_TEST_'

    @staticmethod
    def data_processing_set_debug_trace(text):
    	errorSize = ctypes.c_int(0)
    	sError = ctypes.c_wchar_p()
    	res = capi.dll.DataProcessing_set_debug_trace(utils.to_char_ptr(text), ctypes.byref(utils.to_int32(errorSize)), ctypes.byref(sError))
    	if errorSize.value != 0:
>   		raise errors.DPFServerException(sError.value)
E     ansys.dpf.gate.errors.DPFServerException: Invalid API pointer when calling function DataProcessing_set_debug_trace

.../hostedtoolcache/Python/3.10.19....../x64/lib/python3.10.../gate/generated/data_processing_capi.py:73: DPFServerException
test_server\test_server.py::test_server::TestServer::test_server_debug[server_config2]
Stack Traces | 16.7s run time
self = <test_server.TestServer object at 0x0000021D4BBF7B80>
server_config = <ansys.dpf.core.server_factory.ServerConfig object at 0x0000021D4BBC07C0>
tmp_path = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi5')

    def test_server_debug(self, server_config, tmp_path):
        from pathlib import Path
    
        server_instance = start_local_server(config=server_config)
>       server_instance.start_debug(tmp_path / Path("DEBUG_TEST_"))

test_server\test_server.py:186: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox\test-server\lib\site-packages\ansys\dpf\core\server_types.py:730: in start_debug
    api.data_processing_set_debug_trace(text=str(folder_path))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

text = 'D:\\a\\pydpf-core\\pydpf-core\\.tox\\test-server\\tmp\\pytest-of-unknown\\pytest-0\\test_server_debug_server_confi5\\DEBUG_TEST_'

    @staticmethod
    def data_processing_set_debug_trace(text):
>   	raise NotImplementedError
E    NotImplementedError

.tox\test-server\lib\site-packages\ansys\dpf\gate\generated\data_processing_abstract_api.py:40: NotImplementedError
test_server\test_server.py::test_server::TestServer::test_server_debug[server_config3]
Stack Traces | 16.8s run time
self = <test_server.TestServer object at 0x0000021D4BBF7C40>
server_config = <ansys.dpf.core.server_factory.ServerConfig object at 0x0000021D4BBC0820>
tmp_path = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi8')

    def test_server_debug(self, server_config, tmp_path):
        from pathlib import Path
    
        server_instance = start_local_server(config=server_config)
        server_instance.start_debug(tmp_path / Path("DEBUG_TEST_"))
        f = dpf.core.field_from_array([1.0], server=server_instance)
        fwd = dpf.core.operators.utility.forward(any=f, server=server_instance)
        fwd.run()
        server_instance.stop_debug()
        debug_folder = sorted(tmp_path.glob("DEBUG_TEST_*"))
        assert len(debug_folder) == 1
        init_path = debug_folder[0] / Path("init.log")
>       assert init_path.exists()
E       AssertionError: assert False
E        +  where False = exists()
E        +    where exists = WindowsPath('D:.../pydpf-core/pydpf-core/.tox.../pytest-of-unknown/pytest-0/test_server_debug_server_confi8/DEBUG_TEST_2025_11_24-10-24-02/init.log').exists

test_server\test_server.py:194: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

except:
warnings.warn(traceback.format_exc())

def start_debug(self, folder_path: str | Path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it really be at the server API? Wouldn't it be better in core, close to load plugin...

Also, I would create a context manager (similar design to licensing context manager)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'll put tests but I wanted to validate the API first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it at the Server level because it is a specific server you ask for its debug info.
I can make a context manager and also expose it at the ansys.dpf.core level as a global command which would take the global server.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense here, as it is for a given server.

Just a question, I remember we had an issue in the past that was fixed for data sources when the client was in a OS (say Windows) and the server was another (say Linux), that there was some path adaptation. I think that was fixed. Is this affected by that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense here, as it is for a given server.

Just a question, I remember we had an issue in the past that was fixed for data sources when the client was in a OS (say Windows) and the server was another (say Linux), that there was some path adaptation. I think that was fixed. Is this affected by that?

yes you are right, I am now adding the same logic here.

@PProfizi
Copy link
Contributor Author

PProfizi commented Oct 7, 2025

@cbellot000 @rafacanton while testing I found a weird behavior:

The test starts a server, sets a folder for the debug trace, then runs a forward operator.
The DEBUG_TEST_*** folder is correctly created for each test configuration, but only the first has a init.log file, with the traces for all 5 runs appended to the same file.

from pathlib import Path

server_instance = start_local_server(config=server_config)
server_instance.start_debug(tmp_path / Path("DEBUG_TEST_"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You miss a "/" or "" at the end

@rafacanton
Copy link
Contributor

@cbellot000 @rafacanton while testing I found a weird behavior:

The test starts a server, sets a folder for the debug trace, then runs a forward operator. The DEBUG_TEST_*** folder is correctly created for each test configuration, but only the first has a init.log file, with the traces for all 5 runs appended to the same file.

@PProfizi The rule is that each new DPF server and thread has its own init.log file. Can you add the "" or "/"? In that case, each DPF server should write a new temp subffolder under the "DEBUG_TEST_" folder and you should see different init files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants